package cn.wolfcode.crm.service.imp;

import cn.wolfcode.crm.domain.EmployeeNeeds;
import cn.wolfcode.crm.mapper.EmployeeNeedsMapper;
import cn.wolfcode.crm.qo.EmployeeNeedsQueryObject;
import cn.wolfcode.crm.qo.PageResult;
import cn.wolfcode.crm.service.IEmployeeNeedsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class EmployeeNeedsServiceImpl implements IEmployeeNeedsService {

    @Autowired
    private EmployeeNeedsMapper employeeNeedsMapper;

    @Override
    public void deleteByPrimaryKey(Long id) {
        employeeNeedsMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void insert(EmployeeNeeds record) {
        employeeNeedsMapper.insert(record);
    }

    @Override
    public PageResult query(EmployeeNeedsQueryObject qo) {
        int count = employeeNeedsMapper.rows(qo);
        if (count == 0) {
            return new PageResult(count, Collections.EMPTY_LIST);
        } else {
            return new PageResult(count, employeeNeedsMapper.queryForList(qo));
        }
    }

    @Override
    public List<EmployeeNeeds> selectAll() {
        return employeeNeedsMapper.selectAll();
    }

    @Override
    public void updateByPrimaryKey(EmployeeNeeds record) {
        employeeNeedsMapper.updateByPrimaryKey(record);
    }
}
